package com.LeetCode.dp;

import org.junit.Test;

/**
 * LeetCode 第k个数字
 */
public class getKNumber {

    public int getKthMagicNumber(int k) {
        int a = 0, b = 0, c = 0;
        int[] dp = new int[k+1];
        dp[0] = 1;
        for(int i =1 ; i <= k; i++){
            dp[i] = Math.min(Math.min(dp[a] * 3,dp[b] * 5) , dp[c] * 7);
            if(dp[i] == 3 * dp[a]) a++;
            if(dp[i] == 5 * dp[b]) b++;
            if(dp[i] == 7 * dp[c]) c++;

        }
        return dp[k];
    }

    @Test
    public void test(){
        System.out.println(getKthMagicNumber(5));
    }
}
